package com.qf.servlet;

import com.qf.service.Impl.StulnfoServiceImpl;
import com.qf.service.StulnfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author a1275872671
 * @version v1.0
 * @project guanqipeng
 * @package com.qf.servlet
 * @company
 * @date 2024/4/30 11:52
 */
@WebServlet("/deleteservlet")
public class deleteservlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        if (id==null||id.trim().equals("")){
            response.getWriter().write("id为空");
            return;
        }
        StulnfoService stulnfoService=new StulnfoServiceImpl();
        try {
            stulnfoService.delete(Integer.parseInt(id));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        response.sendRedirect("stulnfo.jsp");
    }
}
